<template>
  <div class="app-container">
    <eHeader :query="query" :dicts="dicts" />
    <!--表格渲染-->
    <el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
      <el-table-column prop="timestamp" label="日志时间">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.timestamp) }}</span>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" prop="query" label="查询语句" />
      <el-table-column prop="query_time" label="查询时间" />
      <el-table-column prop="lock_time" label="锁占用时间" />
      <el-table-column prop="rows_sent" label="返回行数" />
      <el-table-column prop="rows_examined" label="优化器扫描行数" />
    </el-table>
    <!--分页组件-->
    <el-pagination
      :total="total"
      :current-page="page"
      style="margin-top: 8px;"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="sizeChange"
      @current-change="pageChange"
    />
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import initData from '@/mixins/initData'
import initDict from '@/mixins/initDict'
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
export default {
  components: { eHeader },
  mixins: [initData, initDict],
  data() {
    return {
      delLoading: false, sup_this: this
    }
  },
  created() {
    this.$nextTick(() => {
      this.init()
      // 加载数据字典
      this.getDict('remove_status')
    })
  },
  methods: {
    parseTime,
    checkPermission,
    beforeInit() {
      this.url = 'api-log/syslog/slowQueryLog'
      const sort = 'sort'
      this.params = { page: this.page, size: this.size, sort: sort }
      const query = this.query
      if (query.value) {
        this.params['searchValue'] = query.value
      }
      return true
    }
  }
}
</script>

<style scoped>

</style>
